package com.dhj.jvmstudy.chapter10;

/**
 * 字节码处理文件，将字节码保存到excel中
 */
public class DealClass {

    public static void main(String[] args) {
        String hexCode = "cafe babe 0000 0034 0016 0a00 0400 1209\n" +
                "0003 0013 0700 1407 0015 0100 036e 756d\n" +
                "0100 0149 0100 063c 696e 6974 3e01 0003\n" +
                "2829 5601 0004 436f 6465 0100 0f4c 696e\n" +
                "654e 756d 6265 7254 6162 6c65 0100 124c\n" +
                "6f63 616c 5661 7269 6162 6c65 5461 626c\n" +
                "6501 0004 7468 6973 0100 214c 636f 6d2f\n" +
                "6468 6a2f 6a76 6d73 7475 6479 2f63 6861\n" +
                "7074 6572 3130 2f44 656d 6f3b 0100 0361\n" +
                "6464 0100 0328 2949 0100 0a53 6f75 7263\n" +
                "6546 696c 6501 0009 4465 6d6f 2e6a 6176\n" +
                "610c 0007 0008 0c00 0500 0601 001f 636f\n" +
                "6d2f 6468 6a2f 6a76 6d73 7475 6479 2f63\n" +
                "6861 7074 6572 3130 2f44 656d 6f01 0010\n" +
                "6a61 7661 2f6c 616e 672f 4f62 6a65 6374\n" +
                "0021 0003 0004 0000 0001 0002 0005 0006\n" +
                "0000 0002 0001 0007 0008 0001 0009 0000\n" +
                "0038 0002 0001 0000 000a 2ab7 0001 2a04\n" +
                "b500 02b1 0000 0002 000a 0000 000a 0002\n" +
                "0000 0003 0004 0004 000b 0000 000c 0001\n" +
                "0000 000a 000c 000d 0000 0001 000e 000f\n" +
                "0001 0009 0000 003d 0003 0001 0000 000f\n" +
                "2a2a b400 0205 60b5 0002 2ab4 0002 ac00\n" +
                "0000 0200 0a00 0000 0a00 0200 0000 0700\n" +
                "0a00 0800 0b00 0000 0c00 0100 0000 0f00\n" +
                "0c00 0d00 0000 0100 1000 0000 0200 11";

        String[] subCode = hexCode.toUpperCase().split(" ");
        for (String ele : subCode) {
            if (ele.length() == 2) {
                System.out.print(ele.substring(0, 2));

            } else if (ele.length() == 4) {
                System.out.print(ele.substring(0, 2) + "\t" + ele.substring(2, 4) + "\t");

            } else {
                System.out.print(ele.substring(0,2)+"\t"+ele.substring(2,4)+ele.substring(4,5)+ele.substring(5,7)+"\t"+ele.substring(7,9)+"\t");
            }
        }
        System.out.println("");

    }

}
